*This code reproduces the analyses of the experiment on politicians. 
*Running the code produces a set of figures that are saved in the working directory

clear
use politicians_experiment

*FIGURE 1
reg quality treated control, cl(id) nocons
coefplot, title("Quality", color(black) size(medsmall) ) coeflab(treated = "Treatment" control = "Control") color(black) graphregion(color(gs16)) ciopts(color(black)) plotregion(style(none)) vertical  ylab(.6 (.05) .8, angle(0) nogrid)
graph save Graph "treatment_politicians_quality.gph", replace
reg ranking treated control, cl(id) nocons
coefplot, title("Ranking", color(black) size(medsmall) ) coeflab(treated = "Treatment" control = "Control") color(black) graphregion(color(gs16)) ciopts(color(black)) plotregion(style(none)) vertical  ylab(.6 (.05) .8, angle(0) nogrid)
graph save Graph "treatment_politicians_ranking.gph", replace

graph combine "treatment_politicians_quality.gph" "treatment_politicians_ranking.gph", rows(1)  graphregion(color(gs16)) title("Experimental results", color(black) size(small))

*TABLE 1
foreach y in quality ranking  {
reg `y' minority, cl(id)
}

*TABLE 3
*immigration share
foreach y in quality ranking {
reg `y' minority minorityXimshare imshare, cl(id)
}

*enop
foreach y in quality ranking {
reg `y' minority minorityXenop enop, cl(id)
}

*leftparty
foreach y in quality ranking {
reg `y' minority minorityXleftparty leftparty, cl(id)
}

*motivated to not appear prejudiced
foreach y in quality ranking {
reg `y' minority minorityXnonracist nonracist, cl(id)
}

*TABLE A1
su quality1 quality2 ranking1 ranking2 electable1 electable2 minority male university age missage west north leftparty if minority!=. & profile==1
 
*TABLE A3 (column 1)
reg minority male university age missage west north leftparty if profile==1, r
testparm male university age missage west north leftparty 

*FIGURE A4
twoway (hist quality if treated==1,  xtitle("Quality") percent fcolor(none) lcolor(black) graphregion(color(gs16))  plotregion(style(none)) vertical ylab(, angle(0) nogrid) )(hist quality if treated==0, percent fcolor(none) lcolor(red)), legend(order(1 "Treated" 2 "Control") region(col(white)))
graph save Graph "dist.figs_quality.gph", replace
twoway (hist ranking if treated==1,  xtitle("Ranking") percent fcolor(none) lcolor(black) graphregion(color(gs16))  plotregion(style(none)) vertical ylab(, angle(0) nogrid) )(hist ranking if treated==0, percent fcolor(none) lcolor(red)), legend(order(1 "Treated" 2 "Control") region(col(white)))
graph save Graph "dist.figs_ranking.gph", replace
graph combine "dist.figs_quality.gph" "dist.figs_ranking.gph", rows(1)  graphregion(color(gs16))

*TABLE A5
reg electable minority, cl(id)
reg electable minority age missage, cl(id)
reg electable minority male university age missage west north leftparty, cl(id)

*TABLE A6
reg electable malik warsam, cl(id)
reg electable malik warsam age missage, cl(id)
reg electable malik warsam male university age missage west north leftparty, cl(id)

*TABLE A7
foreach y in quality ranking{
reg `y' minority, cl(id)
reg `y' minority age missage, cl(id)
reg `y' minority male university age missage west north leftparty, cl(id)
}

*TABLE A8
foreach y in quality ranking{
reg `y' minority if profile==1, cl(id)
reg `y' minority if profile==2, cl(id)
}

*TABLE A9
foreach y in quality ranking{
reg `y' malik warsam, cl(id)
reg `y' malik warsam age missage, cl(id)
reg `y' malik warsam male university age missage west north leftparty, cl(id)
}

*TABLE A11
foreach y in quality ranking {
reg `y' minority minorityXimcpd imcpd, cl(id)
reg `y' minority minorityXimcpd imcpd leftparty male university age missage west north, cl(id)
}

*TABLE A12
foreach y in quality ranking {
reg `y' minority##nonracist minority##c.leftpartyc minority##c.malec minority##c.universityc minority##c.agec minority##c.missagec minority##c.westc minority##c.northc, cl(id)
}

*TABLE A14
foreach y in quality ranking {
reg `y' minority  others_notme, cl(id)	
reg `y' minority minorityXnonracist nonracist  minorityXothers_notme others_notme, cl(id)
}
